﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.ActiveRecord;
using ZDSoft.UPMS.Model.BusinessPart;

namespace ZDSoft.UPMS.Model.SystemPart
{
    /// <summary>
    /// 用户类
    /// </summary>
    /// Author：刘祖民
    /// CreateTime:2013-5-22

    [ActiveRecord("SystemUser")]
    public class User : ModelBase<User>
    {
        /// <summary>
        /// 用户名
        /// </summary>
        [Property]
        public string Account { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        [Property]
        public string Password { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        [Property]
        public string Name { get; set; }

        /// <summary>
        /// 用户工号或学号
        /// </summary>
        [Property]
        public string UserNumber { get; set; }

        /// <summary>
        /// 激活状态
        /// </summary>
        [Property]
        public bool IsActive { get; set; }

        /// <summary>
        /// 用户是否丢失密码
        /// </summary>
        [Property]
        public bool IsReset { get; set; }

        /// <summary>
        /// 拥有的角色
        /// </summary>
        [HasAndBelongsToMany(typeof(Role), Table = "User_Manager", ColumnKey = "UserID", ColumnRef = "RoleID")]
        public IList<Role> Roles { get; set; }

        /// <summary>
        /// 所属行政机构
        /// </summary>
        [BelongsTo("OrganizationID")]
        public Organization Organization { get; set; }


        /// <summary>
        /// 当用户是学生时的平时成绩
        /// </summary>

        [HasMany(typeof(Score), ColumnKey = "UserID")]
        public IList<Score> Scores { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [Property]
        public string Remark { get; set; }

        /// <summary>
        /// 教师
        /// </summary>
        [HasMany(typeof(TeacherTeachingCourse), ColumnKey = "UserID", Inverse = true, Lazy = true)]
        public IList<TeacherTeachingCourse> TeacherTeachingCourses { get; set; }

        /// <summary>
        /// 记录学生的情况
        /// </summary>
        [HasMany(typeof(Situation), ColumnKey = "StudentID", Inverse = true, Lazy = true)]
        public IList<Situation> Situations { get; set; }

    }
}
